import service from "@/utils/response";

export const Login = data => {
  return service({
    url: '/user/login',
    method: 'post',
    data
  })}


  export const ListBusiness = (data) => {  
    return service({  
        url: '/business/listBusiness',  
        method: 'get',  
        params:  data  
    });  
}

export const searchBusinessByBusinessName = (data) =>{
    return service({
        url: '/business/searchBusinessByBusinessName',
        method: 'get',
        params: data
    })
}

export const listBusinessByType = (data) => {
    return service({
        url:'/business/listBusinessByType',
        method: 'get',
        params: data
    })
}

export const listFoodByBussinessId = (businessId,page=1,pageSize=10000) => {
    return service({
        url:'/food/getFoodByBusinessId',
        method:'get',
        params: {
            businessId,
            page,
            pageSize
        }
    })
}

export const addFood = (businessId,foodId) => {
    return service({
        url:'/cart/add',
        method:'POST',
        data: {
            foodId,
            businessId   
        }
    })
}

export const decreaseFood = (businessId,foodId) => {
    return service({
        url:'/cart/decrease',
        method:'POST',
        data: {
            foodId,
            businessId   
        }
    })
}

export const getBusinessById = (businessId) => {
    return service({
        url:'/business/getBusinessById',
        method:'get',
        params:{
            businessId
        }
    })
}

export const getCartByBusinessId = (businessId,page=1,pageSize=1000) => {
    return service({
        url:'/cart/getCart',
        method:'get',
        params:{
            businessId,
            page,
            pageSize
        }
    })
}

export const Register = data => {
  return service({
    url: '/user/register',
    method: 'post',
    data
  })
}

export const Upload = data => {
  return service({
    url: '/upload',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

export const listOrder = data => {
  return service({
    url: '/order/listOrderOfUser',
    method: 'get',
    params: data
  })
}

export const listAddress = data => {
  return service({
    url: `/deliveryAddress/getAddress`,
    method: 'get',
    params: data
  })
}

export const getCurrentUser = data => {
  return service({
    url: '/user/getUserById',
    method: 'get',
    data
  })
}

export const Logout = data => {
  return service({
    url: '/user/logout',
    method: 'get',
    data
  })
}

export const UpdatePassword = data => {
  return service({
    url: '/user/updateUserPwd',
    method: 'post',
    data
  })
}

export const AddAddress = data => {
  return service({
    url: '/deliveryAddress/add',
    method: 'post',
    data
  })
}

export const deleteAddress = data => {
  return service({
    url: '/deliveryAddress/delete',
    method: 'post',
    data
  })
}

export const pay = data => {
  return service({
    url: '/order/pay',
    method: 'get',
    params: data
  })
}

export const submitOrder = data => {
  return service({
    url: '/order/createOrder',
    method: 'post',
    data
  })
}

export const updateAddress = data => {
  return service({
    url: '/deliveryAddress/update',
    method: 'post',
    data
  })
}